<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/WEB-INF/jsp/common/style.jsp"%>
<script type="text/javascript">

</script>

<script type="text/javascript">
$(document).ready(function(e) {
    $(".select1").uedSelect({
		width : 345			  
	});
	$(".select2").uedSelect({
		width : 167  
	});
	$(".select3").uedSelect({
		width : 100
	});
});
function select_all(obj) {
    if (obj.checked) {
        $("#dgrdproduct :checkbox").attr("checked", true);
    }else {
        $("#dgrdproduct :checkbox").attr("checked", false);
    }
    //checkCount();
}
</script>

</head>


<body  style="background:none;">
   <div id="seach" class="mainInner"> 
   
   		<form id="seachForm" name="seachForm" action="${pageContext.request.contextPath}/basic/item/seachItemIndex"	method="post">
   		<input name="status" value="${status}" type="hidden" />
   		 <div class="Dgw mb10">
		
            <div class="table-scroll">
				<table  style="line-height: 30px; text-align: left;" >
					<tr>

						<td style="width: 100px">商品ID:</td>
						<td><input name="itemId"  value="${itemId}" class="scinput" /></td>
						<td style="width: 100px">商品名称:</td>
						<td><input name="itemName"  value="${itemName}" class="scinput" /></td>
						<td></td><td></td>
					</tr>


				</table>
			</div>
        </div>
   		<div class="tools" style="margin-top:10px">
    
		     <ul class="toolbar" style="margin-left: 0px">
		        <li class="click"  onclick="javascript:seach()"><span><img src="../../images/ico06.png" /></span>查询</li>
		        </ul>
		   </div>
   
    <div id="content">
		
        <div class="table-scroll">
			<table class="tab mb10 tabson" cellspacing="0" cellpadding="6"  rules="all" border="1" id="dgrdproduct" style="border-collapse: collapse; font-size: 12px;">
				<thead>
				<tr>
					<th><input id="CheckAll" type="checkbox" onclick="select_all(this);" /></th>
					<th>商品ID</th>
					<th>商品名称</th>
					<th>属性</th>
					<th>规格</th>
					<th>状态</th>
					<th>采购进价</th>
					<th>经销价</th>
					<th>零售价</th>
					<th>库存数量</th>
				</tr>
				</thead>
				<tbody>
				<c:forEach items="${items}" var="item" varStatus="itemStatus">
					<tr id="row_${item.id}">
						<td><input id="${item.id}"    type="checkbox" name="itemCheck" onclick="checkBoxCount(this);"
								   itemId="${item['id']}"
								   itemName="${item['item_name']}"
								   purPrice="${item['pur_price']}"
								   barCode="${item['bar_code']}"
								   salePrice="${item['sale_price']}"
								   disPrice="${item['dis_price']}"
								   inventoryNum="${item['inventory_num']}"
								   attr="${item['attr1']}<span>-</span>${item['attr2']}"
						/>
						</td>
						<td>${item.id}</td>
						<td>${item.item_name}</td>

						<td>${item.attr1}</td>
						<td>${item.attr2}</td>
						<c:choose>
							<c:when test="${item.status == '0'}">
								<td  align="center" >下架</td>
							</c:when>
							<c:when test="${item.status == '1'}">
								<td  align="center" >上架</td>
							</c:when>
							<c:otherwise>
								<td></td>
							</c:otherwise>
						</c:choose>
						<td><fmt:formatNumber value="${item.pur_price}" type="currency" pattern="0.00"/></td>
						<td><fmt:formatNumber value="${item.dis_price}" type="currency" pattern="0.00"/></td>
						<td><fmt:formatNumber value="${item.sale_price}" type="currency" pattern="0.00"/></td>
						<td>${item.inventory_num}</td>
					</tr>
				</c:forEach>
				</tbody>
			</table>


		</div><div class="pagin">
   			<vp:pages cpage="${page.cpage}" totalCount="${page.totalCount}" />
  
   		</div>
   		</br>
   		</br>
   		</br>
   			<div class="tools" style="margin-top:10px">   

    	   
		     	<input  type="button" class="btnclass" value="提交" onclick="javascript:addItem();" />	
    	</div>
    
    </form>
    
    </div>
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	</script>
	<script type="text/javascript">
	function seach(){
		$("#cpage").val(1);
		oksubmit();
	}
	function oksubmit() {
	    $("#btnOk").attr("disabled", "disabled");	  
	    var objform = document.getElementById('seachForm');
	    objform.submit();
	}
	 var orderIds = "";
	function getSelectItem() {
				$("#dgrdproduct tbody tr input").each(function () {
					var id=$(this).attr('id');
					var itemId=$(this).attr('itemId'); 
					var itemName=$(this).attr('itemName'); 
					var purPrice=$(this).attr('purPrice'); 
					var barCode=$(this).attr('barCode');
					var salePrice=$(this).attr('salePrice'); 
					var attr=$(this).attr('attr'); 
					var inventoryNum=$(this).attr('inventoryNum'); 
					
					var orderId=id;
					if ($(this).attr("checked") == "checked") {
						var id=id;
						//alert(id);
						parent.addItem(id,itemId,itemName,purPrice, barCode,salePrice,attr,inventoryNum);
						//function addItem(id,storageTypeName,locationId,locationName, itemId,itemName,attr,qty){
						orderIds = orderIds == "" ? orderId : id + "," + orderId;
					}
				});
		}
	function addItem(){
		getSelectItem();
		if(orderIds==''){
			layer.alert('请选择要添加的商品');
		}else{ 
			layer.alert('添加成功');
			
		}
	}
	</script>
</body>
</html>
	